package com.hzh302.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.hzh302.spring.hello.MessagePrinter;
import com.hzh302.spring.hello.MessageService;

@Configuration
@ComponentScan
public class Application {
	@Bean
	MessageService messageService() {
		return new MessageService() {

			public String getMessage() {
				return "我要胜利！";
			}

		};
	}
	
	public static void main(String[] args){
		ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
		MessagePrinter pessagePrinter = context.getBean(MessagePrinter.class);
		pessagePrinter.pringMessage();
	}
}
